﻿using System.Windows;
using System.Windows.Input;
using GMap.NET;

namespace CHDTools;

using GMap.NET.MapProviders;

/// <summary>
/// 页面主窗口类 MainWindow.xaml
/// </summary>
public partial class MainWindow : Window {
    public MainWindow() {
        //初始化主窗口
        InitializeComponent();
        // this.SourceInitialized += (o, e) => { Console.WriteLine("SourceInitialized"); }; //程序加载源事件
        // this.Activated += (o, e) => { Console.WriteLine("Activated"); }; //程序获取焦点事件
        // this.Loaded += (o, e) => { Console.WriteLine("Loaded"); }; //程序加载完毕事件
        // this.ContentRendered += (o, e) => { Console.WriteLine("ContentRendered"); }; //程序渲染完毕事件
        // this.Closed += (o, e) => { Console.WriteLine("Closed"); }; //程序关闭事件


        //初始化地图组件
        InitMap();
    }

    /// <summary>
    /// 地图初始化方法
    /// </summary>
    void InitMap() {
        // 启用webview 组件 显示
        // string url = "http://www.tuwang.com/app/3D/";
        // // 将WebView的Source属性设置为构建的URL
        // webView.Source = new System.Uri(url);

        // 设置高德地图作为底图
        MapControl.MapProvider = AMapProvider.Instance; //高德 china 地图
        MapControl.MapProvider = GMapProviders.BingHybridMap; //高德 china 地图
        MapControl.Manager.Mode = AccessMode.ServerAndCache;
        MapControl.ShowCenter = false; //不显示中心十字点
        MapControl.DragButton = MouseButton.Right; //右键拖拽地图
        PointLatLng center = new PointLatLng(45.7448, 122.65874);
        MapControl.Position = center;
        MapControl.Zoom = 13;
        // 启用鼠标滚轮缩放
        MapControl.MouseWheelZoomEnabled = true;
    }
}